package com.vancouver.knows.ui.activity.set;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;

import com.pangu.util.StringUtil;
import com.vancouver.knows.MainApplication;
import com.vancouver.knows.R;
import com.vancouver.knows.ui.base.BaseActivity;
import com.vancouver.knows.ui.common.ListViewForScrollView;
import com.vancouver.knows.business.BSharedPrefManager;
import com.vancouver.knows.business.BusinessModule;
import com.vancouver.knows.business.task.mark.MessageRemindTaskMark;

public class MessageRemindActivity extends BaseActivity {

	private Context mContext;
	@Bind(R.id.common_tips)
	TextView mCommonTips;
	@Bind(R.id.common_back)
	ImageView mCommonBack;
	@Bind(R.id.listview)
	ListViewForScrollView mListView;

	private MessageListAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.message_remind);
		mContext = MessageRemindActivity.this;
		setViews();

	}

	private void setViews() {
		Intent intent = getIntent();
		String tips = intent.getStringExtra("COMMON_TIPS");
		mCommonTips.setText(tips);

		mAdapter = new MessageListAdapter(mContext);
		mListView.setDividerHeight(0);
		mListView.setAdapter(mAdapter);
	}

	@OnClick(R.id.common_back)
	public void onCommonBackClick() {
		finish();
	}

	@Override
	protected void onStop() {
		BusinessModule bModule = ((MainApplication) getApplication()).getBusinessModule();
		MessageRemindTaskMark aTaskMark = bModule.getTaskMarkPool().createMessageRemindTaskMark();
		BSharedPrefManager sharePrefManager = ((MainApplication) getApplicationContext()).getSharedPrefManager();
		String userId = sharePrefManager.getUserId();
		if (StringUtil.isEmptyString(userId)) {
			return;
		}
		bModule.getServiceWrapper().setMessageRemind(null, aTaskMark, userId,
				sharePrefManager.getMyArticleNewComment(), sharePrefManager.getHaveAtCommentMessage(),
				sharePrefManager.getMyFollowedBusiness());

		super.onStop();
	}
}